import request from "@/utils/request";
//获取路由表
const asyncRoute = []
const routs = function getAsyncRouter() {
  return request({
    url: "/v1/admin/function/list",
    method: "post",
    headers: {
      account_type: "1"
    },
    data: {}
  }).then(res => {
    if (res.tip === "成功") {
      var data = res.funcionLists;
      if (data.constructor === Array) {//一级
        data.map((val, inx) => {
          if (val.funcions !== null) { //二级
            var child = [];
            val.funcions.map((vall, indd) => {
              if (vall.funcions !== null) {
                var childd = [];
                vall.funcions.map((valll, inddd) => { //三级
                  childd.push({
                    name: valll.func_name,
                    meta: {
                      title: valll.func_name
                    }
                  })
                })
              }
              child.push({      //二级
                name: vall.func_name,
                meta: {
                  title: vall.func_name
                },
                children: childd
              })
            })
            asyncRoute.push({      //一级
              name: val.func_name,
              meta: {
                title: val.func_name
              },
              children: child,
            })
          } else {           
            asyncRoute.push({
              name: val.func_name,
              meta: {
                title: val.func_name
              },
            })
          }
        })
      } else {
        asyncRoute.push({
          name: data.func_name,
          meta: {
            title: val.func_name
          },
        })
      }
    }
  })
}
